package org.kumas.sgrpc.common.constants;

import java.util.concurrent.ExecutorService;
import java.util.regex.Pattern;

import org.kumas.sgrpc.common.URL;

/**
 * sg-rpc-java:CommonConstants
 *
 * @author KumasZhang
 * @version 1.0
 * @since 2021-04-11 12:01
 */
public interface CommonConstants {
    String SGRPC = "sgrpc";
    String LAZY_CONNECT_KEY = "lazy";

    String SIDE_KEY = "side";

    String PROVIDER = "provider";

    String CONSUMER = "consumer";

    String PROVIDER_SIDE = "provider";

    String CONSUMER_SIDE = "consumer";

    String APPLICATION_KEY = "application";

    String DEFAULT_PROTOCOL = "sgrpc";

    String DEFAULT_THREAD_NAME = "Sgrpc";

    int DEFAULT_CORE_THREADS = 0;

    int DEFAULT_THREADS = 200;

    String METHODS_KEY = "methods";

    String METHOD_KEY = "method";

    String THREADPOOL_KEY = "threadpool";
    String DEFAULT_CLIENT_THREADPOOL = "CachedThreadPool";

    String THREAD_NAME_KEY = "threadname";

    String CORE_THREADS_KEY = "corethreads";

    String THREADS_KEY = "threads";

    String QUEUES_KEY = "queues";

    int DEFAULT_QUEUES = 0;

    int DEFAULT_ALIVE = 60 * 1000;

    String TIMEOUT_KEY = "timeout";

    int DEFAULT_TIMEOUT = 1000;
    String ALIVE_KEY = "alive";
    String TIME_COUNTDOWN_KEY = "timeout-countdown";
    String ENABLE_TIMEOUT_COUNTDOWN_KEY = "enable-timeout-countdown";
    int DEFAULT_SERVER_SHUTDOWN_TIMEOUT = 10000;

    String DEFAULT_KEY_PREFIX = "default.";

    String DEFAULT_KEY = "default";

    String PREFERRED_KEY = "preferred";

    String DUMP_DIRECTORY = "dump.directory";

    String INTERFACE_KEY = "interface";

    String GROUP_KEY = "group";

    String PATH_KEY = "path";
    String VERSION_KEY = "version";
    String PROTOCOL_KEY = "protocol";

    String SGRPC_VERSION_KEY = "sgrpc";
    String MONITOR_KEY = "monitor";
    String CLUSTER_KEY = "cluster";
    String USERNAME_KEY = "username";
    String PASSWORD_KEY = "password";
    String HOST_KEY = "host";
    String PORT_KEY = "port";
    String DEFAULT_VERSION = "0.0.0";
    String BROADCAST_CLUSTER = "broadcast";

    /**
     * @since 2.7.8
     */
    char COMMA_SEPARATOR_CHAR = ',';

    String COMMA_SEPARATOR = ",";

    String DOT_SEPARATOR = ".";

    Pattern COMMA_SPLIT_PATTERN = Pattern.compile("\\s*[,]+\\s*");

    String PATH_SEPARATOR = "/";

    String PROTOCOL_SEPARATOR = "://";

    String PROTOCOL_SEPARATOR_ENCODED = URL.encode(PROTOCOL_SEPARATOR);

    String REGISTRY_SEPARATOR = "|";

    String UNDERLINE_SEPARATOR = "_";

    String SEPARATOR_REGEX = "_|-";

    String GROUP_CHAR_SEPARATOR = ":";

    String HIDDEN_KEY_PREFIX = ".";

    String DOT_REGEX = "\\.";

    Pattern REGISTRY_SPLIT_PATTERN = Pattern.compile("\\s*[|;]+\\s*");

    Pattern D_REGISTRY_SPLIT_PATTERN = Pattern.compile("\\s*[|]+\\s*");

    String SEMICOLON_SEPARATOR = ";";

    Pattern SEMICOLON_SPLIT_PATTERN = Pattern.compile("\\s*[;]+\\s*");

    Pattern EQUAL_SPLIT_PATTERN = Pattern.compile("\\s*[=]+\\s*");

    Pattern COLON_SPLIT_PATTERN = Pattern.compile("\\s*[:]+\\s*");

    String DEFAULT_PROXY = "javassist";

    String DEFAULT_DIRECTORY = "dubbo";

    String EXECUTOR_SERVICE_COMPONENT_KEY = ExecutorService.class.getName();

    String CLASSPATH_URL_PREFIX = "classpath:";
    String REMOVE_VALUE_PREFIX = "-";

    String ANYHOST_KEY = "anyhost";

    String ANYHOST_VALUE = "0.0.0.0";

    String LOCALHOST_KEY = "localhost";

    String LOCALHOST_VALUE = "127.0.0.1";
    String PID_KEY = "pid";

    String TIMESTAMP_KEY = "timestamp";

    /**
     * package version in the manifest
     */
    String RELEASE_KEY = "release";

    int MAX_PROXY_COUNT = 65535;

    String SGRPC_IP_TO_BIND = "SGRPC_IP_TO_BIND";
    String SGRPC_PREFERRED_NETWORK_INTERFACE = "sgrpc.network.interface.preferred";

    String HEARTBEAT_EVENT = null;
    String MOCK_HEARTBEAT_EVENT = "H";
    String READONLY_EVENT = "R";

    String KEEP_ALIVE_KEY = "keep.alive";
    String SSL_ENABLED_KEY = "ssl-enabled";

    String SERVICE_PATH_PREFIX = "service.path.prefix";

    String IO_THREADS_KEY = "iothreads";

    String SGRPC_PROPERTIES_KEY = "sgrpc.properties.file";

    String DEFAULT_SGRPC_PROPERTIES = "sgrpc.properties";

    String $INVOKE = "$invoke";
    String $INVOKE_ASYNC = "$invokeAsync";
    String GENERIC_PARAMETER_DESC = "Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;";
    String TIMEOUT_ATTACHMENT_KEY = "_TO";
    String GENERIC_SERIALIZATION_NATIVE_JAVA = "nativejava";

    String GENERIC_SERIALIZATION_DEFAULT = "true";

    String GENERIC_SERIALIZATION_BEAN = "bean";

    String GENERIC_RAW_RETURN = "raw.return";

    String GENERIC_SERIALIZATION_PROTOBUF = "protobuf-json";

    String GENERIC_WITH_CLZ_KEY = "generic.include.class";

    /**
     * The limit of callback service instances for one interface on every client
     */
    String CALLBACK_INSTANCES_LIMIT_KEY = "callbacks";

    String SERVICE_FILTER_KEY = "service.filter";
    String REFERENCE_INTERCEPTOR_KEY = "reference.interceptor";
    String REFERENCE_FILTER_KEY = "reference.filter";
    String INVOKER_LISTENER_KEY = "invoker.listener";
    String EXPORTER_LISTENER_KEY = "exporter.listener";

    String TAG_KEY = "sgrpc.tag";
    String STUB_EVENT_KEY = "sgrpc.stub.event";

    String CLASS_DESERIALIZE_BLOCK_ALL = "dubbo.security.serialize.blockAllClassExceptAllow";

    String CLASS_DESERIALIZE_ALLOWED_LIST = "dubbo.security.serialize.allowedClassList";

    String CLASS_DESERIALIZE_BLOCKED_LIST = "dubbo.security.serialize.blockedClassList";

    String ENABLE_NATIVE_JAVA_GENERIC_SERIALIZE = "dubbo.security.serialize.generic.native-java-enable";

    String SERIALIZE_BLOCKED_LIST_FILE_PATH = "security/serialize.blockedlist";
    public static final String DEFAULT_SGRPC_PROTOCOL_VERSION = "2.0.2";
    int DEFAULT_CALLBACK_INSTANCES = 1;
}
